<template>
  <div>
    <h1>三级分类页面</h1>


    <el-tree
      @node-click="nodeClick"
      :data="dataList"
      :props="defaultProps"
     
    >
     
    
    </el-tree>

  </div>
</template>

<script>
export default {
  data() {
    return {
     
      dataList: [],

      defaultProps: {
        children: "children",
        label: "name",
      },
    };
  },
  

  created() {
    this.getDataList();
  },
  methods: {
    nodeClick(node){
      console.log("被点击的对象",node)
      //子组件给父组件传递数据
      //第一位方法名称,第二位传递的值
      if(node.catLevel==3){
        this.$emit("tree-node-click",node)

      }
      
    },

    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl("/product/category/tree/list"),
        method: "get",
        params: this.$http.adornParams(),
      }).then(({ data }) => {
        this.dataList = data.data;
      });
    },
   
  },
};
</script>
